﻿using System.Collections;
using System.Collections.Generic;

/// <summary>
/// 人物修炼的武学
/// </summary>
public class PersonageWuxue {

    /// <summary>
    /// 武学id
    /// </summary>
	public string WuxueId { get; set; }
    /// <summary>
    /// 武学
    /// </summary>
    public Wuxue Wuxue { get; set; }
    /// <summary>
    /// 当前等级
    /// </summary>
    public int Grade { get; set; }
    /// <summary>
    /// 当前经验
    /// </summary>
    public int Exp { get; set; }
    /// <summary>
    /// 完整程度（1~10）
    /// </summary>
    public int Intact { get; set; }

    public PersonageWuxue() {
        this.Grade = 1;
        this.Exp = 0;
    }

    public PersonageWuxue(string wuxueId) : this(wuxueId, 10) {

    }

    public PersonageWuxue(string wuxueId, int intact) : this() {
        this.WuxueId = wuxueId;
        this.Wuxue = GlobalData.Instance.WuxueDictionary[wuxueId];
        this.Intact = intact;
    }

    /// <summary>
    /// 获得该武学对应等级信息
    /// </summary>
    /// <returns>武学等级信息</returns>
    public WuxueGrade GetWuxueGrade() {
        List<WuxueGrade> wuxueGrades = this.Wuxue.WuxueGrades;
        foreach (WuxueGrade wuxueGrade in wuxueGrades) {
            if (this.Grade == wuxueGrade.Grade) {
                return wuxueGrade;
            }
        }
        return wuxueGrades[wuxueGrades.Count - 1];
    }
}
